<!Doctype html>
<html>
<head>
    <meta charset='UTF-8'>
    <title>Document</title>
</head>
<body>

</body>
<script>
// 创建一个标签
var span = document.createElement("span");
document.body.appendChild(span)
document.onmousemove = function(e){
    var e = e || window.event;
    var x = e.clientX;
    var y = e.clientY;
    span.innerText = '跟随光标的文字';
    setStyle(span,{
        position:'absolute',
        left:x + "px",
        top:y + "px"
    })
}



function setStyle(ele,styleObj){
    for(var attr in styleObj){
        ele.style[attr] = styleObj[attr]
    }
}
</script>
</html>